﻿using System.ComponentModel;
using System.Configuration;

namespace Needle.Core.Configuration
{
    /// <summary>
    /// Describes an object.
    /// </summary>
    public class ServiceElement : ConfigurationElement
    {
        /// <summary>
        /// The service type. This is the type under which the service 
        /// is registered with the container. 
        /// </summary>
        [ConfigurationProperty(Element.Type, IsRequired = true, IsKey = true)]
        [Description("The service type. This is the type under which the "+
            "service is registered with the container.")]
        public string Type
        {
            get { return (string)this[Element.Type]; }
            set { this[Element.Type] = value; }
        }

        /// <summary>
        /// The dependency id of the object implementing the service.
        /// </summary>
        [ConfigurationProperty(Element.Id, IsRequired = true)]
        [Description("The dependency id of the object implementing the service.")]
        public string Id
        {
            get { return (string)this[Element.Id]; }
            set { this[Element.Id] = value; }
        }

        /// <summary>
        /// True if the service is created on demand,
        /// false if the service is created on startup.
        /// </summary>
        [ConfigurationProperty(Element.Lazyload, IsRequired = false, DefaultValue = true)]
        [Description("True if the service is created on demand, " +
            "false if the service is created on startup.")]
        public bool Lazyload
        {
            get { return (bool)this[Element.Lazyload]; }
            set { this[Element.Lazyload] = value; }
        }
    }
}
